//
//
//  NSDate+IDPExtension.h
//  IDP
//
//  Created by douj on 13-3-6.
//  Copyright (c) 2012年 baidu. All rights reserved.
//

#import <Foundation/Foundation.h>

#define D_MINUTE	60
#define D_HOUR		3600
#define D_DAY		86400
#define D_WEEK		604800
#define D_YEAR		31556926

@interface NSDate (IDPExtension)

- (NSString *)stringWithDateFormat:(NSString *)format;

+ (NSTimeInterval)timeIntervalSince1970;

+ (NSDate *) dateTomorrow;
+ (NSDate *) dateYesterday;
+ (NSDate *) dateCWithDaysFromNow: (NSUInteger) days;
+ (NSDate *) dateWithDaysCBeforeNow: (NSUInteger) days;
+ (NSDate *) dateWithHoursFromNow: (NSUInteger) dHours;
+ (NSDate *) dateWithHoursBeforeNow: (NSUInteger) dHours;
+ (NSDate *) dateWithMinutesFromNow: (NSUInteger) dMinutes;
+ (NSDate *) dateWithMinutesBeforeNow: (NSUInteger) dMinutes;

// Comparing dates
- (BOOL) isEqualToDateIgnoringTime: (NSDate *) aDate;
- (BOOL) isToday;
- (BOOL) isTomorrowCustom;
- (BOOL) isYesterday;
- (BOOL) isSameWeekAsDate: (NSDate *) aDate;
- (BOOL) isThisWeek;
- (BOOL) isNextWeek;
- (BOOL) isLastWeek;
- (BOOL) isSameYearAsDateCustom: (NSDate *) aDate;
- (BOOL) isThisYear;
- (BOOL) isNextYear;
- (BOOL) isLastYear;
- (BOOL) isEarlierThanDate: (NSDate *) aDate;
- (BOOL) isLaterThanDate: (NSDate *) aDate;

// Adjusting dates
- (NSDate *) dateByAddingCDays: (NSUInteger) dDays;
- (NSDate *) dateBySubtractingDays: (NSUInteger) dDays;
- (NSDate *) dateByAddingHoursCustom: (NSUInteger) dHours;
- (NSDate *) dateBySubtractingHours: (NSUInteger) dHours;
- (NSDate *) dateByAddingCMinutes: (NSUInteger) dMinutes;
- (NSDate *) dateBySubtractingMinutes: (NSUInteger) dMinutes;
- (NSDate *) dateAtStartOfDay;

// Retrieving intervals
- (NSInteger) minutesAfterDate: (NSDate *) aDate;
- (NSInteger) minutesBeforeDate: (NSDate *) aDate;
- (NSInteger) hoursAfterDate: (NSDate *) aDate;
- (NSInteger) hoursBeforeDate: (NSDate *) aDate;
- (NSInteger) daysAfterDate: (NSDate *) aDate;
- (NSInteger) daysBeforeDate: (NSDate *) aDate;

//转换日期为string

+ (NSString *)convertDateFomatterToStringWith:(NSString *)aInterVal  formatter:(NSString *)daFormatter;

+ (NSString *)convertDateIntervalToStringWith:(NSString *)aInterVal;
+ (NSString *)convertDateFomatterToStringWith:(NSString *)aInterVal;
+ (NSString *)convertDateIntervalToStringWith:(long long)max min:(long long) min;

+ (NSString *)convertDateHM:(NSString *)aInterVal;
+ (NSString *)convertDateyHd:(NSString *)aInterVal;
+ (NSString *)convertDateYM:(NSString *)aInterVal;

+ (NSString *)getNextMouth:(NSString *)year_mouth;
+ (NSString *)getLastMouth:(NSString *)year_mouth;
+ (NSString *)getCurrentDate;
+ (NSDate *) stringToDate:(NSString *)stringFormat;

+ (NSString *)getTimeFomatterToStringWith:(NSString *)aInterVal;

+ (NSString *)getCurrentDateTwo;
+ (NSString *)getActivityTimeWithInterVal:(NSString *)aInterVal;
+ (NSString *)getTimeWithTimeStamp:(NSString *)timeStamp;

// 根据时间戳获取当前的时间
//+(NSString *)getCurrentString:(NSString *)timeInterval;
//+(NSString *)getCurrent13String:(NSString *)timeInterval;

+(NSString *)formatTimeSinceNow:(NSTimeInterval)timestamp;

// Decomposing dates
@property (readonly) NSInteger nearestHour;
@property (readonly) NSInteger hour;
@property (readonly) NSInteger minute;
@property (readonly) NSInteger seconds;
@property (readonly) NSInteger day;
@property (readonly) NSInteger month;
@property (readonly) NSInteger week;
@property (readonly) NSInteger weekday;
@property (readonly) NSInteger nthWeekday; // e.g. 2nd Tuesday of the month == 2
@property (readonly) NSInteger year;

@end
